import pandas as pd
df=pd.read_csv('../../file/图书信息.csv', encoding='utf_8_sig')
index=pd.read_csv('../../file/三级分类信息.csv', encoding='utf_8_sig')
data=[]
id=1
for row in df.iterrows():
    third_category=row[1]['third_category']
    matching_row=index[index['category']==third_category]
    f_id=matching_row['f_id'].values[0]
    s_id=matching_row['s_id'].values[0]
    t_id=matching_row['id'].values[0]
    title=row[1]['title']
    author=row[1]['author']
    cover=row[1]['cover']
    href=row[1]['href']
    des=row[1]['des']
    data.append({
        'id': id,
        'f_id': f_id,
        's_id': s_id,
        't_id': t_id,
        'title':  title,
        'author': author,
        'cover': cover,
        'href': href,
        'des': des
    })
    id=id+1

data=pd.DataFrame(data)
data.to_csv('图书信息表.csv',index=False,encoding='utf_8_sig')